<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<meta charset="utf-8" />
		<title>业务台账变更申请记录</title>		
		
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="static/js/jquery-1.7.2.js" />
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
			<link rel="stylesheet" href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
			
			
</head>
<body>
<div id="payment"></div>
<div id="payment1"></div>
</body>
<script type="text/javascript">
Ext.onReady(function(){
	var store = Ext.create('Ext.data.Store', {
		fields: ["app_code",
		         "advance_pay_amount",
		         "app_change_reason",
		         "bill_code",
		         "app_time",
		         "payment_type"],
		pageSize:10,
		id:'store',
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>businessAccountApply/findRecordInfo',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad:{start:0,limit:30},
	});
	var store1 = Ext.create('Ext.data.Store', {
		fields: [
		         "bill_code",
		         "amount"],
		pageSize:10,
		id:'store1',
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>businessAccountApply/findRecordDetail',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad:{start:0,limit:30},
	});
	var grid = Ext.create('Ext.grid.Panel', {
		title:"业务台账变更申请记录",
		renderTo:'payment',
		store: store,
		id:'grid',
		forceFit: true,
		height: 325,
		stripeRows:true,
		columnLines: true,
// 		plugins:[invoice_unit_cellEditing],
		selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
		columns: [
			{text: 'payment_type', dataIndex: 'payment_type',hidden:true},
			{text: '申请号', dataIndex: 'app_code'},
			{text: '申请时间', dataIndex: 'app_time'},
			{text: '预付金额', dataIndex: 'advance_pay_amount'},
			{text: '业务编号', dataIndex: 'bill_code'},
			{text: '变更原因', dataIndex: 'app_change_reason'},
		],
		bbar: [{
			xtype: 'pagingtoolbar',
			store: store,
			displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
			emptyMsg: "没有数据",
			beforePageText: "当前页",
			afterPageText: "共{0}页",
			displayInfo: true
		}],

		tbar: [{text: '审核通过', icon: '<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/cog_edit.png', handler: function (){
			var records = grid.getSelectionModel().getSelection();
   			if(records.length==0){
   				Ext.Msg.alert("提示","请选中需要审批的记录");return;
   			}
   			if(records.length>1){
   				Ext.Msg.alert("提示","只能审批一条记录");return;
   			}
   			
	      		Ext.Ajax.request({
	      			 url: '<%=basePath%>businessAccountApply/updateState',
	      			 params:{app_code:records[0].data.app_code,app_state:"1",payment_type:records[0].data.payment_type,bill_code:records[0].data.bill_code},
	      			 method: 'POST',
	        			success: function () {
	        				Ext.MessageBox.alert("提示","审批通过");
	        				store.load();
//							javascript:location.reload();
							
	        			}
	      		});
		} },{text: '驳回', icon: '<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/cog_edit.png', handler: function (){
			var records = grid.getSelectionModel().getSelection();
   			if(records.length==0){
   				Ext.Msg.alert("提示","请选中需要审批的记录");return;
   			}
   			if(records.length>1){
   				Ext.Msg.alert("提示","只能审批一条记录");return;
   			}
   			var win = Ext.create("Ext.window.Window", {
 				title: "编辑",
 				modal:true,
 				width: 800,
 				height: 180,
 				maximizable: true,
 				closeAction:'destroy',
 				layout: "fit",
//  				margin: '3 3 0',
 		        buttonAlign:'center',
 				items: [ 
 				        	{
 				        		xtype: "form",
 				        		id:'form',
 				        		bodyPadding: 5,
 				        		layout: "hbox",
 				        		defaults: {
 				        			border: false,
 				        			flex: 1,
 				        			anchor: '100%'
 				        		},
 				        		fieldDefaults: {
 				        			labelWidth: 92,
 				        			labelAlign: "right",
 				        			//flex: 1,
 				        			margin: 5,
 				        			labelStyle: 'color:green;'
 				        		},
 				        		items: [{
    					        			xtype: 'textarea',
    					        			id:"reject_reason",
	       					        		name: 'reject_reason',
	       					        		fieldLabel: '驳回原因',
	       					        		allowBlank:false
	       					        	}]
 				        	}
 				        ],
 				       buttons: [{
	       		            text: '保存',
	       		            handler: function(){
	       		            	var reject_reason = Ext.getCmp('reject_reason').getValue();
	       		            	Ext.Ajax.request({
	       		      			 url: '<%=basePath%>businessAccountApply/updateState',
	       		      			 params:{app_code:records[0].data.app_code,app_state:"0",reject_reason:reject_reason,payment_type:records[0].data.payment_type},
	       		      			 method: 'POST',
	       		        			success: function () {
	       		        				Ext.MessageBox.alert("提示","驳回成功");
	       		        				store.load();
	       		        				win.close();
//	       								javascript:location.reload();
	       								
	       		        			}
	       		      		});
	       		            }
	       		        },{
	       		            text: '关闭',
	       		            handler: function(){
	       		            	win.close();
	       		            }
	       		        }]
 			});
       		win.show();
	      		
		} }
		],
	listeners: {
		'itemclick': function (view, record, item, index, e) {
			var store = Ext.getCmp('grid1').getStore();
			store.on('beforeload', function(store,options) {  
		            var new_params = {  
		            		app_code:record.data.app_code
		            };  

		            Ext.apply(store.proxy.extraParams,new_params);  
		        });  
		        store.load();  
		}
	},
	});
	var grid1 = Ext.create('Ext.grid.Panel', {
		renderTo:'payment1',
		store: store1,
		id:'grid1',
		forceFit: true,
		height: 325,
		title:'拆分记录',
		stripeRows:true,
		columnLines: true,
// 		plugins:[invoice_unit_cellEditing],
		selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
		columns: [
			{text: 'check_id', dataIndex: 'check_id',hidden:true},
			{text: '业务编号', dataIndex: 'bill_code'},
			{text: '金额', dataIndex: 'amount'},
		],
		bbar: [{
			xtype: 'pagingtoolbar',
			store: store1,
			displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
			emptyMsg: "没有数据",
			beforePageText: "当前页",
			afterPageText: "共{0}页",
			displayInfo: true
		}],

		tbar: [],
	});
});
</script>
</html>